<%@ page import="top.liuzhenyu.study.javawebjdbc.entity.News" %>
<%@ page import="top.liuzhenyu.study.javawebjdbc.dao.NewsDAO" %><%--
  Created by IntelliJ IDEA.
  User: liuzhenyu
  Date: 2024/5/23
  Time: 12:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加新闻</title>
</head>
<body>
    <%
        request.setCharacterEncoding("utf-8");
        News news = new News();
        news.setTitle(request.getParameter("title"));
        news.setBody(request.getParameter("body"));
        int i = NewsDAO.insert(news);
        String message = "添加失败";
        if (i == 1) {
            message = "添加成功";
        }
    %>

    <script>
        alert("<%=message%>");
        location.href = 'newinsert.jsp';
    </script>

</body>
</html>
